<%--
  Created by IntelliJ IDEA.
  User: legion
  Date: 2020/12/12
  Time: 14:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="../js/bootstrap.min.js"></script>
    <!--开关按钮-->
<%--    <script type="text/javascript" src="lib/jquery.js"></script>--%>
    <script type="text/javascript"src="js/on_off_switch.js"></script>
    <link rel="stylesheet" href="css/on_off_switch.css" type="text/css">

</head>
<!--div样式-->
<style type="text/css">
    .div
    {
        display:none;
        border:1px solid ;
        height:50%;
        width:30%;
        position:absolute;/*让节点脱离文档流,我的理解就是,从页面上浮出来,不再按照文档其它内容布局*/
        top:24%;/*节点脱离了文档流,如果设置位置需要用top和left,right,bottom定位*/
        left:24%;
        z-index:2;/*个人理解为层级关系,由于这个节点要在顶部显示,所以这个值比其余节点的都大*/
        background: white;
    }
    #over
    {
        width: 100%;
        height: 100%;
        opacity:0.3;/*设置背景色透明度,1为完全不透明,IE需要使用filter:alpha(opacity=80);*/
        filter:alpha(opacity=80);
        display: none;
        position:absolute;
        top:0;
        left:0;
        z-index:1;
        background-color: rgb(0,0,0);
    }



    .testswitch {
        position: relative;
        float: left;
        width: 90px;
        margin: 0;
        -webkit-user-select:none;
        -moz-user-select:none;
        -ms-user-select: none;
    }

    .testswitch-checkbox {
        display: none;
    }

    .testswitch-label {
        display: block;
        overflow: hidden;
        cursor: pointer;
        border: 2px solid #999999;
        border-radius: 20px;
    }

    .testswitch-inner {
        display: block;
        width: 200%;
        margin-left: -100%;
        transition: margin 0.3s ease-in 0s;
    }

    .testswitch-inner::before, .testswitch-inner::after {
        display: block;
        float: right;
        width: 50%;
        height: 30px;
        padding: 0;
        line-height: 30px;
        font-size: 14px;
        color: white;
        font-family:
                Trebuchet, Arial, sans-serif;
        font-weight: bold;
        box-sizing: border-box;
    }

    .testswitch-inner::after {
        content: attr(data-on);
        padding-left: 10px;
        background-color: #00e500;
        color: #FFFFFF;
    }

    .testswitch-inner::before {
        content: attr(data-off);
        padding-right: 10px;
        background-color: #EEEEEE;
        color: #999999;
        text-align: right;
    }

    .testswitch-switch {
        position: absolute;
        display: block;
        width: 22px;
        height: 22px;
        margin: 4px;
        background: #FFFFFF;
        top: 0;
        bottom: 0;
        right: 56px;
        border: 2px solid #999999;
        border-radius: 20px;
        transition: all 0.3s ease-in 0s;
    }

    .testswitch-checkbox:checked + .testswitch-label .testswitch-inner {
        margin-left: 0;
    }

    .testswitch-checkbox:checked + .testswitch-label .testswitch-switch {
        right: 0px;
    }


</style>

<script>
    /**
     * 订单管理中 订单详情 根据sid查询订单
     */
    function getIds(did,userId,userId1,userId2){
        $("#div1").show()
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:4,sid:did},
            success:function (data,status,xhr) {
                if(data==""){
                    return;
                }
                /**
                 * 计算提成
                 */
                data = JSON.parse(data);
                var royalties=""
                if(userId==userId1 && userId==userId2){
                    royalties =  (parseFloat(data.totalPrice)-parseFloat(data.cost_price)-parseFloat(data.otherCost))*0.87*0.4

                }else if(userId == userId1 && userId1 != userId2){
                    royalties = (parseFloat(data.totalPrice)-parseFloat(data.cost_price)-parseFloat(data.otherCost))*0.87*0.1

                }else if(userId != userId1 && userId1 == userId2){
                    royalties = (parseFloat(data.totalPrice)-parseFloat(data.cost_price)-parseFloat(data.otherCost))*0.87*0.3
                }


                $("#name1").val(data.name);//名称
                $("#amount1").val(data.amount);//数量
                $("#price1").val(data.price);//单价
                $("#totalPrice1").val(data.totalPrice);//总价
                $("#costPrice1").val(data.cost_price);//成本
                $("#totalCostPrice1").val(data.totalCostPrice);//总成本
                $("#royalties1").val(royalties);//提成
                $("#createTime1").val(data.createTime);//创建时间
                $("#otherCost1").val(data.otherCost);//其他成本
                $("#bill1").val(data.bill);//有无票据
                $("#userName1").val(data.userName);//客户姓名
                $("#address1").val(data.address);//地址
                $("#phone1").val(data.phone);//联系电话
                $("#billInfo").val(data.billInfo);//开票资料
                $("#invoiceId").val(data.invoiceId);//库存编号
                $("#remarks1").val(data.remarks);//备注
            }
        })
    }
    /**
     * 订单管理中 根据sid查询库存号
     */
    function fun(sid){
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:7,sid:sid},
            success:function (data,status,xhr) {
                data = JSON.parse(data);
                $("#stockNumber").empty();
                var optionNumber="";
                for (var a=0;a<data.length;a++){
                    optionNumber+="<option>"+data[a].number+"</option>"
                }
                $("#stockNumber").html(optionNumber)
            }
        })
    }
    /**
     * 库存编号
     */
    function fun1(sid){
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:7,sid:sid},
            success:function (data,status,xhr) {
                data = JSON.parse(data);
                $("#stockNumber1").empty();
                var optionNumber="";
                for (var a=0;a<data.length;a++){
                    optionNumber+="<option>"+data[a].number+"</option>"
                }
                $("#stockNumber1").html(optionNumber)
            }
        })
    }
    /**
     * 根据页数查询数据
     */
    function selectLine(a){
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:13,'line':a,name:$("#name").val()},
            success: function (data,status,xhr) {
                  if(data==""){
                      return;
                  }
                  data = JSON.parse(data)
                $("#tbody").empty();
                var tr = "";
                for (var a=0;a<data.length;a++){
                    /**
                     * 计算提成
                     */
                    var royalties=""
                    if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                        royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                    }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                        royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                    }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                        royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                    }
                    if(data[a].status=="0"){
                        tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>未出库</button></td><td>";

                    }else if(data[a].status=="1"){
                        tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>已出库</button></td><td>";

                    }else if(data[a].status=="2"){
                        tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                    }

                    tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                        "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                }
                $("#tbody").append(tr)

            }
        })
    }
    /**
     * 点击已出库修改数据库库存
     */
    function library(did,amount,number){
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:14,id:did,amount:amount,number:number},
            success: function (data,status,xhr) {
                $.ajax({//查询全部订单
                    url:"http://localhost:8080/myServlet",
                    type:"post",
                    data:{type:1},
                    success:function (data,status,xhr) {
                        data = JSON.parse(data);
                        $("#tbody").empty();
                        var tr = "";
                        for (var a = 0; a < data.length; a++) {
                            /**
                             * 计算提成
                             */
                            var royalties=""
                            if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                                royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                            }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                                royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                            }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                                royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                            }
                            if (data[a].status == "0") {
                                tr += "<tr style='background-color: royalblue'><td><input type='radio'  value='" + data[a].did + "' name='radio'><td>" + data[a].orderId + "</td><td>" + data[a].name +
                                    "</td><td>" + data[a].amount + "</td><td>" + data[a].price + "</td><td>" +
                                    data[a].totalPrice + "</td><td>" + data[a].cost_price + "</td><td>" + data[a].totalCostPrice + "<td>"
                                    + royalties + "</td><td>" + data[a].createTime + "</td><td>"
                                    + data[a].otherCost + "</td><td>" + data[a].bill + "</td><td><button id='library" + a + "' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='" + data[a].did + "'>未出库</button></td><td>";

                            } else if (data[a].status == "1") {
                                tr += "<tr><td><input type='radio'  value='" + data[a].did + "' name='radio'><td>" + data[a].orderId + "</td><td>" + data[a].name +
                                    "</td><td>" + data[a].amount + "</td><td>" + data[a].price + "</td><td>" +
                                    data[a].totalPrice + "</td><td>" + data[a].cost_price + "</td><td>" + data[a].totalCostPrice + "<td>"
                                    + royalties + "</td><td>" + data[a].createTime + "</td><td>"
                                    + data[a].otherCost + "</td><td>" + data[a].bill + "</td><td><button id='library" + a + "' value='" + data[a].did + "'>已出库</button></td><td>";

                            } else if (data[a].status == "2") {
                                tr += "<tr style='background-color: red'><td><input type='radio'  value='" + data[a].did + "' name='radio'><td>" + data[a].orderId + "</td><td>" + data[a].name +
                                    "</td><td>" + data[a].amount + "</td><td>" + data[a].price + "</td><td>" +
                                    data[a].totalPrice + "</td><td>" + data[a].cost_price + "</td><td>" + data[a].totalCostPrice + "<td>"
                                    + royalties + "</td><td>" + data[a].createTime + "</td><td>"
                                    + data[a].otherCost + "</td><td>" + data[a].bill + "</td><td><button id='library" + a + "' value='" + data[a].did + "'>退货</button></td><td>";

                            }

                            tr += "<input type='button' value='订单详情' onclick='getIds(" + data[a].did + ","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page" + a + "'>" +
                                "<input type='button' value='生成标签' id='label" + a + "' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                        }
                        $("#tbody").append(tr)
                        //刷新按钮组
                        $.ajax({
                            url:"http://localhost:8080/myServlet",
                            type:"post",
                            data:{type:12,'name':$("#name").val(),
                                'finish':$("#finish").val(),'begin':$("#begin").val()},
                            success: function (data,status,xhr) {
                                console.log(data)
                                if(data==""){
                                    return;
                                }
                                data = JSON.parse(data)
                                $("#lineDiv").empty()
                                let button = ""
                                for(let a=1;a<=data.lines;a++){
                                    button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                                }
                                $("#lineDiv").append(button)
                            }
                        })
                    }
                    })
            }
        })
    }
    $(function () {
        /**
         * 查询订单 设置分页页数
         */
        $.ajax({
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:12,'name':$("#name").val(),
                'finish':$("#finish").val(),'begin':$("#begin").val()},
            success: function (data,status,xhr) {
                console.log(data)
                if(data==""){
                    return;
                }
                data = JSON.parse(data)
                $("#lineDiv").empty()
                let button = ""
                for(let a=1;a<=data.lines;a++){
                    button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                }
                $("#lineDiv").append(button)
            }
        })
    })
    /**
     * 点击生成订单图片
     */
    function x(name,amount){
       window.location.href="/myServlet?type=15&name="+name+"&amount="+amount;
    }

     //查询数据
    $(function () {

        /**
         * 订单管理中 查询全部数据
         */
        $.ajax( {//查询全部订单
            url:"http://localhost:8080/myServlet",
            type:"post",
            data:{type:1},
            success:function (data,status,xhr) {
                data =  JSON.parse(data);
                $("#tbody").empty();
                var tr = "";
                //业务员身份不符合要求 设置不能执行删除操作
                if(data[0].types!="0"){
                    document.getElementById("delete").disabled=true ;//设置不可点击
                }
                for (var a=0;a<data.length;a++){
                    /**
                     * 计算提成
                     */
                    var royalties=""
                    if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                        royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                    }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                        royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                    }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                        royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                    }

                    if(data[a].status=="0"){
                        tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library("+data[a].did+","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>未出库</button></td><td>";

                    }else if(data[a].status=="1"){
                        tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"'  value='"+data[a].did+"'>已出库</button></td><td>";

                    }else if(data[a].status=="2"){
                        tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                            "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                            data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                            +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                            +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                    }

                    tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                        "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                }
                $("#tbody").append(tr)
                /**
                 * 订单管理 根据条件查询订单
                 */
                $("#select").click(function () {//根据name 动态查询订单
                    console.log($("#finish").val()+""+$("#begin").val()+"=======")
                    $.ajax({
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:3,'name':$("#name").val(),
                            'finish':$("#finish").val(),'begin':$("#begin").val()},
                        success:function (data,status,xhr) {
                            if(data==""){
                                return;
                            }
                            data = JSON.parse(data);
                            $("#tbody").empty();
                            var tr = "";
                            //业务员身份不符合要求 设置不能执行删除操作
                            if(data[0].type!="0"){
                                document.getElementById("delete").disabled=true ;//设置不可点击
                            }
                            for (var a=0;a<data.length;a++){
                                /**
                                 * 计算提成
                                 */
                                var royalties=""
                                if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                                    royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                                }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                                    royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                                }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                                    royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                                }


                                if(data[a].status=="0"){
                                    tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>未出库</button></td><td>";

                                }else if(data[a].status=="1"){
                                    tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>已出库</button></td><td>";

                                }else if(data[a].status=="2"){
                                    tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                                }

                                tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                                    "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                            }
                            $("#tbody").append(tr);
                            //刷新按钮组
                            $.ajax({
                                url:"http://localhost:8080/myServlet",
                                type:"post",
                                data:{type:12,'name':$("#name").val(),
                                    'finish':$("#finish").val(),'begin':$("#begin").val()},
                                success: function (data,status,xhr) {
                                    console.log(data)
                                    if(data==""){
                                        return;
                                    }
                                    data = JSON.parse(data)
                                    $("#lineDiv").empty()
                                    let button = ""
                                    for(let a=1;a<=data.lines;a++){
                                        button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                                    }
                                    $("#lineDiv").append(button)
                                }
                            })
                        }
                    })
                })
            }
        })
    })



   //订单详情
    $(function () {
        /**
         * 订单管理中 订单详情 根据cas号 商品名字模糊查询商品名称
         */
        $("#select1").click(function () {//点击查询按钮 根据cas号 商品名字模糊查询商品
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:5,'name':$("#name2").val(),'cas':$("#cas").val()},
                success:function (data,status,xhr) {
                    data = JSON.parse(data);
                    $("#names").empty();
                    var optionName = "";
                    optionName+="<option>选择一个商品</option>"
                    for(var a=0;a<data.length;a++){
                        optionName+="<option value='"+data[a].sid+"'>"+data[a].name+"</option>";
                    }
                    $("#names").html(optionName)

                }
            })
        })
    })
    //添加数据
    $(function () {

        /**
         * 订单管理中 点击按钮显示添加div 并查询全部商品名字
         */
        $("#adds").click(function () {
            $("#div").show();//点击显示添加div
            // 点击添加查询全部商品名字
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:8},
                success:function (data,status,xhr) {
                    data =  JSON.parse(data);
                    var  nameSelect ="<option>请选择一件商品</option>";
                    for(var a=0;a<data.length;a++){
                        nameSelect+="<option value='"+data[a].sid+"'>"+data[a].name+"</option>";
                    }
                    $("#names").html(nameSelect)
                }
            })
        })
        /**
         * 订单管理中 添加一条订单
         */
        $("#submit").click(function () {
            if($("#stockNumber").val()=="" || $("#price").val()=="" || $("#quantity").val()=="" || $("#cost").val()=="" || $("#others").val()=="" || $("#customerName").val()=="" || $("#site").val()=="" || $("#phone").val()=="" || $("#remark").val()==""){
                    alert("请将订单信息填写完整！")
                    return;
            }
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:6,'cas':$("#cas").val(),'name':$("#names").val(),'quantity':$("#quantity").val(),
                    'price':$("#price").val(),'cost':$("#cost").val(),'others':$("#others").val(),
                    'ticket':$("#ticket").val(),'bill':$("#bill").val(),'stockNumber':$("#stockNumber").text(),
                    'customerName':$("#customerName").val(),'site':$("#site").val(),'phone':$("#phone").val(),
                    'remark':$("#remark").val()
                },
                success:function (data,status,xhr) {
                    $("#cas").val("")
                    $.ajax({
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:8},
                        success:function (data,status,xhr) {
                            data =  JSON.parse(data);
                            var  nameSelect ="<option>请选择一件商品</option>";
                            for(var a=0;a<data.length;a++){
                                nameSelect+="<option value='"+data[a].sid+"'>"+data[a].name+"</option>";
                            }
                            $("#names").html(nameSelect)
                        }
                    })//清空选项
                    $("#name2").val("")
                    $("#quantity").val("")
                    $("#price").val("")
                    $("#cost").val("")
                    $("#others").val("")
                    // $("#ticket1").val("0")
                    // $("#ticket1").removeAttribute("checked")
                    // $("#bill").hide()
                    // $("#bill").val("")
                    $("#stockNumber").html("")
                    $("#customerName").val("")
                    $("#site").val("")
                    $("#phone").val("")
                    $("#remark").val("")
                    $("#div").hide()
                    //刷新数据
                    $.ajax({//查询全部订单
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:1},
                        success:function (data,status,xhr) {
                            data =  JSON.parse(data);
                            $("#tbody").empty();
                            var tr = "";
                            //业务员身份不符合要求 设置不能执行删除操作
                            if(data[0].type!="0"){
                                document.getElementById("delete").disabled=true ;//设置不可点击
                            }
                            for (var a=0;a<data.length;a++){

                                /**
                                 * 计算提成
                                 */
                                var royalties=""
                                if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                                    royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                                }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                                    royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                                }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                                    royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                                }


                                if(data[a].status=="0"){
                                    tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>未出库</button></td><td>";

                                }else if(data[a].status=="1"){
                                    tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>已出库</button></td><td>";

                                }else if(data[a].status=="2"){
                                    tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                                }

                                tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                                    "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                            }
                            $("#tbody").append(tr)
                        }
                    })
                    //刷新按钮组
                    $.ajax({
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:12,'name':$("#name").val(),
                            'finish':$("#finish").val(),'begin':$("#begin").val()},
                        success: function (data,status,xhr) {
                            console.log(data)
                            if(data==""){
                                return;
                            }
                            data = JSON.parse(data)
                            $("#lineDiv").empty()
                            let button = ""
                            for(let a=1;a<=data.lines;a++){
                                button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                            }
                            $("#lineDiv").append(button)
                        }
                    })
                }
            })
        })
    })
    //修改数据
    $(function () {
        /**
         * 修改数据
         */
        $("#select2").click(function () {//点击查询按钮 根据cas号 商品名字模糊查询商品
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:5,'name':$("#name3").val(),'cas':$("#cas1").val()},
                success:function (data,status,xhr) {
                    data = JSON.parse(data);
                    $("#name1s").empty();
                    var optionName = "";
                    optionName+="<option>选择一个商品</option>"
                    for(var a=0;a<data.length;a++){
                        optionName+="<option value='"+data[a].sid+"'>"+data[a].name+"</option>";
                    }
                    $("#name1s").html(optionName)

                }
            })
        })

        /**
         * 订单管理中 修改订单
         */
        $("#update").click(function () {
            //获取当前选中单选按钮的value
            var radioValue= $("input[name='radio']:checked").val();
            if(radioValue==undefined){
                alert("请选中一行")
                return;
            }
            $("#divs").show();
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:10,"radioValue":radioValue},
                success:function (data,status,xhr) {
                    data = JSON.parse(data);
                    var orName='';
                    orName+="<option value='"+data.orderId+"'>"+data.name+"</option>";//商品 名称
                    $("#name1s").html(orName);
                    $("#quantity1").val(data.amount);//商品 数量
                    $("#price2").val(data.price)//商品 单价
                    $("#cost1").val(data.cost_price)//商品 成本
                    $("#others1").val(data.otherCost)//其他 成本
                    $("#ticket1").val(data.bill)//是否有票
                    if(	$("#ticket1").val()=="1"){
                        $("#ticket1").attr("checked","checked")
                        $("#tr2").show()
                        $("#bill2").val(data.billInfo)
                    }
                    var orstock="";
                    orstock+="<option>"+data.invoiceId+"</option>"
                    $("#stockNumber1").html(orstock);//库存编号:
                    $("#customerName1").val(data.userName)//客户名称
                    $("#site1").val(data.address)//地址
                    $("#phone2").val(data.phone)//联系电话
                    $("#remark1").val(data.remarks)//备注

                }
            })
        })
        /**
         * 修改订单
         */
        $("#submit1").click(function () {
            //获取被点击的单选按钮的value值
            var radioValue1= $("input[name='radio']:checked").val();
            if(radioValue1==undefined){
                alert("请选中一行")
                return;
            }
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:11,
                    'did':radioValue1,
                    'amount':$("#quantity1").val(),
                    'price':$("#price2").val(),
                    'costPrice':$("#cost1").val(),
                    'other_cost':$("#others1").val(),
                    'bill':$("#ticket1").val(),
                    'bill_info':$("#bill2").val(),
                    'invoiceId':$("#stockNumber1").text(),
                    'userName':$("#customerName1").val(),
                    'address': $("#site1").val(),
                    'phone':$("#phone2").val(),
                    'remarks':$("#remark1").val(),
                    'commodityId':$("#name1s option:first").val()//选择对象的子标签
                },
                success:function (data,status,xhr) {
                    $("#divs").hide()
                    //修改后刷新数据
                    $.ajax({//查询全部订单
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:1},
                        success:function (data,status,xhr) {
                            data =  JSON.parse(data);
                            $("#tbody").empty();
                            var tr = "";
                            //业务员身份不符合要求 设置不能执行删除操作
                            if(data[0].type!="0"){
                                document.getElementById("delete").disabled=true ;//设置不可点击
                            }
                            for (var a=0;a<data.length;a++){

                                /**
                                 * 计算提成
                                 */
                                var royalties=""
                                if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                                    royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                                }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                                    royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                                }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                                    royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                                }

                                if(data[a].status=="0"){
                                    tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>未出库</button></td><td>";

                                }else if(data[a].status=="1"){
                                    tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>已出库</button></td><td>";

                                }else if(data[a].status=="2"){
                                    tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                                }

                                tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                                    "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                            }
                            $("#tbody").append(tr)
                        }
                    })
                    //刷新按钮组
                    $.ajax({
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:12,'name':$("#name").val(),
                            'finish':$("#finish").val(),'begin':$("#begin").val()},
                        success: function (data,status,xhr) {
                            console.log(data)
                            if(data==""){
                                return;
                            }
                            data = JSON.parse(data)
                            $("#lineDiv").empty()
                            let button = ""
                            for(let a=1;a<=data.lines;a++){
                                button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                            }
                            $("#lineDiv").append(button)
                        }
                    })
                }
            })
        })

    })
    //删除数据
    $(function () {

        /**
         * 订单管理中的删除一条数据
         */
        $("#delete").click(function () {
            //获取被点击的单选按钮的value值
            var radioValue= $("input[name='radio']:checked").val();
            if(radioValue==undefined){
                alert("请选中一行")
                return;
            }
            //刷新数据
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:9,'radioValue':radioValue},
                success: function (data,status,xhr) {
                    $.ajax({//查询全部订单
                        url:"http://localhost:8080/myServlet",
                        type:"post",
                        data:{type:1},
                        success:function (data,status,xhr) {
                            data =  JSON.parse(data);
                            $("#tbody").empty();
                            var tr = "";
                            //业务员身份不符合要求 设置不能执行删除操作
                            if(data[0].type!="0"){
                                document.getElementById("delete").disabled=true ;//设置不可点击
                            }
                            for (var a=0;a<data.length;a++){

                                /**
                                 * 计算提成
                                 */
                                var royalties=""
                                if(data[a].user_id==data[a].user_id1 & data[a].user_id==data[a].user_id2){
                                    royalties =  (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.4
                                }else if(data[a].user_id == data[a].user_id1 & data[a].user_id1 != data[a].user_id2){
                                    royalties = (data[a].totalPrice-data[a].totalCostPrice - data[a].otherCost)*0.87*0.1
                                }else if(data[a].user_id != data[a].user_id1 & data[a].user_id1 == data[a].user_id2){
                                    royalties = (data[a].totalPrice - data[a].totalCostPrice - data[a].otherCost)*0.87*0.3
                                }


                                if(data[a].status=="0"){
                                    tr+="<tr style='background-color: royalblue'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' onclick='library(" + data[a].did + ","+data[a].amount+","+data[a].number+")' value='"+data[a].did+"'>未出库</button></td><td>";

                                }else if(data[a].status=="1"){
                                    tr+="<tr><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>已出库</button></td><td>";

                                }else if(data[a].status=="2"){
                                    tr+="<tr style='background-color: red'><td><input type='radio'  value='"+data[a].did+"' name='radio'><td>"+data[a].orderId+"</td><td>"+data[a].name+
                                        "</td><td>"+data[a].amount+"</td><td>"+data[a].price+"</td><td>"+
                                        data[a].totalPrice+"</td><td>"+data[a].cost_price+"</td><td>"+data[a].totalCostPrice+"<td>"
                                        +royalties+"</td><td>"+data[a].createTime+"</td><td>"
                                        +data[a].otherCost+"</td><td>"+data[a].bill+"</td><td><button id='library"+a+"' value='"+data[a].did+"'>退货</button></td><td>";

                                }

                                tr+="<input type='button' value='订单详情' onclick='getIds("+data[a].did+","+data[a].user_id+","+data[a].user_id1+","+data[a].user_id2+")'  id='page"+a+"'>" +
                                    "<input type='button' value='生成标签' id='label"+a+"' onclick='x(\""+data[a].name+"\","+data[a].amount+")'></td></tr>";

                            }
                            $("#tbody").append(tr)
                        }
                    })
                }
            })
            //刷新按钮组
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:12,'name':$("#name").val(),
                    'finish':$("#finish").val(),'begin':$("#begin").val()},
                success: function (data,status,xhr) {
                    console.log(data)
                    if(data==""){
                        return;
                    }
                    data = JSON.parse(data)
                    $("#lineDiv").empty()
                    let button = ""
                    for(let a=1;a<=data.lines;a++){
                        button+="<button onclick='selectLine("+a+")' class=\"btn btn-info\" value='"+a+"'>"+a+"</button>"
                    }
                    $("#lineDiv").append(button)
                }
            })
        })


        /**
         * 开关
         */
        $(document).ready(function() {
            $("#ticket").on('click', function(){
                clickSwitch()
            });

            var clickSwitch = function() {
                if ($("#ticket").is(':checked')) {
                    $("#tr1").show()
                   $("#ticket").val("1")
                } else {
                    $("#tr1").hide()
                    $("#ticket").val("0")
                }
            };
        });

        $(document).ready(function() {
            $("#ticket1").on('click', function(){
                clickSwitch1()
            });

            var clickSwitch1 = function() {
                if ($("#ticket1").is(':checked')) {
                    $("#tr2").show()
                    $("#ticket1").val("1")
                } else {
                    $("#tr2").hide()
                    $("#ticket1").val("0")
                }
            };
        });

        $("#cancel").click(function () {
            $("#cas").val("")
            $.ajax({
                url:"http://localhost:8080/myServlet",
                type:"post",
                data:{type:8},
                success:function (data,status,xhr) {
                    data =  JSON.parse(data);
                    var  nameSelect ="<option>请选择一件商品</option>";
                    for(var a=0;a<data.length;a++){
                        nameSelect+="<option value='"+data[a].sid+"'>"+data[a].name+"</option>";
                    }
                    $("#names").html(nameSelect)
                }
            })//清空选项
            $("#name2").val("")
            $("#quantity").val("")
            $("#price").val("")
            $("#cost").val("")
            $("#others").val("")
            // $("#ticket1").val("0")
            // $("#ticket1").removeAttr("checked")
            // $("#bill").hide()
            // $("#bill").val("")

            $("#stockNumber").html("")
            $("#customerName").val("")
            $("#site").val("")
            $("#phone").val("")
            $("#remark").val("")
            $("#div").hide();//点击关闭添加div
        })
        $("#cancel1").click(function () {
            $("#divs").hide();//点击关闭修改div
        })
        $("#close").click(function () {
            $("#div1").hide();//点击关闭订单详情div
        })
    })

</script>

<body>
<center>
    <div>
        <input id="begin" type="date" placeholder="yyyy-MM-dd">至<input id="finish" type="date" placeholder="yyyy-MM-dd">选择时间

        <input type="text" id="name">商品名
    </div>
    <br/>

    <button id="select" type="button" class="btn btn-info">查询</button>
    <button id="adds" type="button" class="btn btn-info">添加</button>
    <button id="update" type="button" class="btn btn-info">修改</button>
    <button id="delete" type="button"  class="btn btn-info">删除</button>
</center>
<br/>
<table class="table table-bordered"><!--给所有表格中的单元格添加边框-->
    <tr id="tr" class="table-active"><!--在 <tbody> 内添加斑马线形式的条纹-->
        <td></td>
        <td>订单编号</td>
        <td>产品名称</td>
        <td>数量</td>
        <td>单价</td>
        <td>总价</td>
        <td>成本</td>
        <td>总成本</td>
        <td>提成</td>
        <td>提交日期</td>
        <td>其他成本</td>
        <td>是否有票</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    <tbody id="tbody">

    </tbody>
</table>
<!--分页按钮的div-->
<center>
    <div id="lineDiv">

    </div>
</center>

<div class="div" id="div" style="height: 65vh;overflow-y: scroll"><!--添加的div-->
    <table class="table table-bordered">
        <tbody class="table-active">
        <tr><td>输入cas号</td><td><input id="cas"></td></tr>
        <tr><td>输入商品名称:</td><td><input id="name2"></td></tr>
        <!--输入cas号 商品名称 点击按钮查找相应的商品-->
        <tr><td colspan="2" align="center" valign="middle"><button id="select1">查找商品</button></td></tr>
        <tr><td>商品 名称:</td> <td><select id="names" onchange="fun(this.value)" style="width: 200px"></select></td></tr>
        <tr><td>商品 数量:</td> <td><input id="quantity"></td></tr>
        <tr><td>商品 单价:</td> <td><input id="price"></td></tr>
        <tr><td>商品 成本:</td> <td><input id="cost"></td></tr>
        <tr><td>其他 成本:</td> <td><input id="others"></td></tr>
        <tr><td>是否 有票:</td> <td><div class="testswitch">
            <input class="testswitch-checkbox" id="ticket" type="checkbox" value="0">
            <label class="testswitch-label" for="ticket">
                <span class="testswitch-inner" data-on="OFF" data-off="ON"></span>
                <span class="testswitch-switch"></span>
            </label>
        </div></td></tr>
<%--        <input id="ticket" type="button" value="0">--%>
        <tr id="tr1" hidden="hidden"><td>票据:</td> <td><input id="bill" type="text" style="width: 300px;height: 200px"></td></tr>
        <tr><td>库存编号:</td><td><select id="stockNumber" style="width: 200px"></select></td></tr>
        <tr><td>客户名称:</td><td><input id="customerName"></td></tr>
        <tr><td>地址:</td><td><input id="site"></td></tr>
        <tr><td>联系电话:</td><td><input id="phone"></td></tr>
        <tr><td>备注:</td><td><input id="remark"></td></tr>
        <tr><td><button id="submit">提交</button></td><td><button id="cancel">取消</button></td></tr>
        </tbody>
    </table>
</div>


<div class="div" id="divs" style="height: 65vh;overflow-y: scroll"><!--修改的div-->
    <table class="table table-bordered">
        <tbody class="table-active">
        <tr><td>输入cas号</td><td><input id="cas1"></td></tr>
        <tr><td>输入商品名称:</td><td><input id="name3"></td></tr>
        <!--输入cas号 商品名称 点击按钮查找相应的商品-->
        <tr><td colspan="2" align="center" valign="middle"><button id="select2">查找商品</button></td></tr>
        <tr><td>商品 名称:</td> <td><select id="name1s" onchange="fun1(this.value)" style="width: 200px"></select></td></tr>
        <tr><td>商品 数量:</td> <td><input id="quantity1"></td></tr>
        <tr><td>商品 单价:</td> <td><input id="price2"></td></tr>
        <tr><td>商品 成本:</td> <td><input id="cost1"></td></tr>
        <tr><td>其他 成本:</td> <td><input id="others1"></td></tr>
        <tr><td>是否 有票:</td> <td><div class="testswitch">
            <input class="testswitch-checkbox" id="ticket1" type="checkbox" value="0">
            <label class="testswitch-label" for="ticket1">
                <span class="testswitch-inner" data-on="OFF" data-off="ON"></span>
                <span class="testswitch-switch"></span>
            </label>
        </div></td></tr>
        <tr id="tr2" hidden="hidden"><td>票据:</td> <td><input id="bill2" type="text" style="width: 300px;height: 200px"></td></tr>
        <tr><td>库存编号:</td><td><select id="stockNumber1" style="width: 200px"></select></td></tr>
        <tr><td>客户名称:</td><td><input id="customerName1"></td></tr>
        <tr><td>地址:</td><td><input id="site1"></td></tr>
        <tr><td>联系电话:</td><td><input id="phone2"></td></tr>
        <tr><td>备注:</td><td><input id="remark1"></td></tr>
        <tr><td><button id="submit1">修改</button></td><td><button id="cancel1">取消</button></td></tr>
        </tbody>
    </table>
</div>


<div class="div" id="div1" style="height: 75vh;overflow-y: scroll"><!--订单详情的div-->
    <table class="table table-bordered">
        <tbody class="table-active">
        <tr><td>商品 名称:</td> <td><input id="name1" onfocus=this.blur()></td></tr>
        <tr><td>商品 数量:</td> <td><input id="amount1" onfocus=this.blur()></td></tr>
        <tr><td>商品 单价:</td> <td><input id="price1" onfocus=this.blur()></td></tr>
        <tr><td>商品 总价:</td> <td><input id="totalPrice1" onfocus=this.blur()></td></tr>
        <tr><td>商品 成本:</td> <td><input id="costPrice1" onfocus=this.blur()></td></tr>
        <tr><td>商品总成本:</td> <td><input id="totalCostPrice1" onfocus=this.blur()></td></tr>
        <tr><td>业务员提成</td> <td><input id="royalties1" onfocus=this.blur()></td></tr>
        <tr><td>创建时间:</td> <td><input id="createTime1" onfocus=this.blur()></td></tr>
        <tr><td>其他成本:</td> <td><input id="otherCost1" onfocus=this.blur()></td></tr>
        <tr><td>有无票据:</td> <td><input id="bill1" onfocus=this.blur()></td></tr>
        <tr><td>客户姓名:</td> <td><input id="userName1" onfocus=this.blur()></td></tr>
        <tr><td>地址:</td> <td><input id="address1" onfocus=this.blur()></td></tr>
        <tr><td>联系电话:</td> <td><input id="phone1" onfocus=this.blur()></td></tr>
        <tr><td>开票资料:</td> <td><input id="billInfo" onfocus=this.blur()></td></tr>
        <tr><td>库存编号:</td> <td><input id="invoiceId" onfocus=this.blur()></td></tr>
        <tr><td>备注:</td> <td><input id="remarks1" onfocus=this.blur()></td></tr>
        <tr><td><input type="button" value="关闭" id="close" onfocus=this.blur()></td></tr>


        </tbody>
    </table>
</div>

</body>
</html>
